Skip to content

Enhance filtering capabilities#204

Merged
phillip-wenig-frequenz merged 3 commits into
frequenz-floss:v0.x.xfrom
phillip-wenig-frequenz:add-tag-filter
Oct 29, 2025
Merged

Enhance filtering capabilities#204
phillip-wenig-frequenz merged 3 commits into
frequenz-floss:v0.x.xfrom
phillip-wenig-frequenz:add-tag-filter

Conversation

@phillip-wenig-frequenz
Copy link
Copy Markdown
Contributor

  • Tag filtering for gridpool trades: The gridpool_trades() method now accepts a tag parameter to filter trades by tag. The GridpoolTradeFilter dataclass has been updated accordingly.

  • Flexible time filtering with DeliveryTimeFilter: Replaced the restrictive delivery_period parameter with a more flexible delivery_time_filter across gridpool orders and trades methods. The new DeliveryTimeFilter supports:

    • Time interval filtering with optional start/end times
    • Multiple delivery duration filters
    • More granular control over time-based queries
  • New types for time filtering: Added Interval and DeliveryTimeFilter types to support the enhanced filtering API.

@phillip-wenig-frequenz phillip-wenig-frequenz requested a review from a team as a code owner October 28, 2025 11:13
@github-actions github-actions Bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) labels Oct 28, 2025
@phillip-wenig-frequenz phillip-wenig-frequenz marked this pull request as draft October 28, 2025 11:14
- Add `tag` parameter to `gridpool_trades()` method for filtering trades by tag
- Update `GridpoolTradeFilter` dataclass to include `tag` field
- Update equality and hash methods to include tag field
- Update `from_pb()` and `to_pb()` methods to handle tag serialization
- Bump frequenz-api-electricity-trading dependency to 0.9.0
- Update import path for PaginationParams to v1alpha8

Signed-off-by: Phillip Wenig <phillip.wenig@frequenz.com>
@phillip-wenig-frequenz phillip-wenig-frequenz marked this pull request as ready for review October 28, 2025 11:24
Copy link
Copy Markdown
Contributor

@florian-wagner-frequenz florian-wagner-frequenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just some minor nits you might want to consider.

Comment thread src/frequenz/client/electricity_trading/_client.py
Comment thread src/frequenz/client/electricity_trading/_client.py Outdated
Comment thread src/frequenz/client/electricity_trading/_client.py Outdated
Copy link
Copy Markdown
Contributor

@florian-wagner-frequenz florian-wagner-frequenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, seems you missed some spots for the doc-string refinement, but I don't think that's blocking.

trade_ids: List of trade IDs to filter for.
market_side: The market side to filter for.
delivery_period: The delivery period to filter for.
delivery_time_filter: The delivery time to filter for.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: one place you missed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems you missed some more. I prefer the phrasing from line 844, as the time filter is more than just the time(span), but also includes the time granularity.
But it's completely optional.

@phillip-wenig-frequenz phillip-wenig-frequenz added this pull request to the merge queue Oct 29, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 29, 2025
…iltering

This change updates the filtering mechanism for gridpool orders and trades to use a more flexible `DeliveryTimeFilter` instead of the restrictive `DeliveryPeriod`. The new filter supports:

- Time interval filtering with optional start/end times
- Multiple delivery duration filters
- More granular control over time-based queries

Key changes:
- Added `Interval` and `DeliveryTimeFilter` types to support the new filtering API
- Replaced `delivery_period` parameter with `delivery_time_filter` across all client methods
- Updated CLI to construct `DeliveryTimeFilter` from delivery_start parameter
- Migrated tests to use the new filtering types
- Updated API imports from v1 to v1alpha8 for common types
- Removed dependency on frequenz.client.common.pagination in favor of direct protobuf usage

This change maintains backward compatibility by keeping the `delivery_period` parameter in the `create_gridpool_order` method while adding the new `delivery_time_filter` parameter.

Signed-off-by: Phillip Wenig <phillip.wenig@frequenz.com>
Signed-off-by: Phillip Wenig <phillip.wenig@frequenz.com>
@phillip-wenig-frequenz
Copy link
Copy Markdown
Contributor Author

Updated the missed doc string and bumped the frequenz-api-common min version to 0.8.1 as there were some issues with version conflicts in the merge queue: https://github.com/frequenz-floss/frequenz-client-electricity-trading-python/actions/runs/18902533821/job/53952945831#step:2:643

Copy link
Copy Markdown
Contributor

@florian-wagner-frequenz florian-wagner-frequenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@phillip-wenig-frequenz phillip-wenig-frequenz added this pull request to the merge queue Oct 29, 2025
Merged via the queue into frequenz-floss:v0.x.x with commit 29ed2fa Oct 29, 2025
5 checks passed
@phillip-wenig-frequenz phillip-wenig-frequenz deleted the add-tag-filter branch October 29, 2025 10:07
@matthias-wende-frequenz
Copy link
Copy Markdown
Contributor

Thanks @phillip-wenig-frequenz and @florian-wagner-frequenz for taking care!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants